package IT.Servlet;

import IT.DataAccess.DatCatalogoEstado;
import IT.DataAccess.IDatCatalogoEstado;
import IT.Entities.CatalogoEstado;
import java.io.*;
import java.net.*;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.*;
import javax.servlet.http.*;


public class PlantillaActividadTipoServlet extends HttpServlet {
   
   
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=ISO-8859-1");
        PrintWriter out = response.getWriter();
        try {
            IDatCatalogoEstado oDatEstado;
            List<CatalogoEstado> oLista;
            String cTipo="";
            
            if(request.getParameter("nTipo")!=null){
                cTipo=request.getParameter("nTipo");
                oLista=new ArrayList<CatalogoEstado>();                
                oDatEstado=new DatCatalogoEstado();
                
                if(cTipo.equals("1")){
                    oLista=oDatEstado.Buscar(4005);
                }else if(cTipo.equals("2")){
                    oLista=oDatEstado.Buscar(4006);
                }
                
                for(CatalogoEstado ent:oLista){
                    out.printf("<option value='%1s'>%2s</option>", ent.getVal_est_in(), ent.getNom_est_vc());
                }
            }
            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet PlantillaActividadTipo</title>");  
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet PlantillaActividadTipo at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            */
        } finally { 
            out.close();
        }
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
    * Returns a short description of the servlet.
    */
    public String getServletInfo() {
        return "Short description";
    }
    // </editor-fold>
}
